package com.icode.dao;

import com.icode.core.model.AbstractEntity;
import org.hibernate.Session;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ZhongGang
 * Date: 13-6-23
 * Time: 上午1:32
 */
public interface EntityDao {

    Session currentSession();

    <T extends AbstractEntity> void saveOrUpdate(T t);

    <T extends AbstractEntity> void saveOrUpdate(List<T> t);

    <T extends AbstractEntity> List<T> findAll(Class<T> t);

    <T extends AbstractEntity> List<T> findAll(Class<T> t, boolean active);

    <T extends AbstractEntity> List<T> findActiveEntities(Class<T> t);

    <T extends AbstractEntity> List<T> findDeactiveEntities(Class<T> t);

    <T extends AbstractEntity> void deactive(String guid, Class<T> clazz);

    <T extends AbstractEntity> void active(String guid, Class<T> clazz);

    <T extends AbstractEntity> void delete(String guid, Class<T> clazz);

    <T extends AbstractEntity> T findByGuid(Class<T> clazz, String guid);

    <T extends AbstractEntity> List<T> findByGuids(Class<T> clazz, List<String> guids);

    <T extends AbstractEntity> List<T> findByGuids(String[] guids, Class<T> clazz);

    <T extends AbstractEntity> List<T> findByGuids(Class<T> clazz, String... guids);
}
